package com.longma.server.pojo;

import com.longma.server.constant.enums.ResponseCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author HIBO
 * @Description json返回实体
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResponseMessage<T> {
    /**
     * 状态码
     */
    private int code;

    /**
     * 消息
     */
    private String msg;

    /**
     * 数据
     */
    private T data;

    public ResponseMessage(ResponseCode responseCode, T data) {
        responseCode = responseCode == null ? ResponseCode.FAIL : responseCode;
        this.code = responseCode.getCode();
        this.msg = responseCode.getMessage();
        this.data = data;
    }
}
